import request from '@/config/axios'
import type { TplUpdateVo, TplCreateVo, TplQueryDto, TplCreateDirVo } from './types'

// 查询左边树
export const getResTreeApi = async () => {
  return await request.get({ url: '/cms/siteres/tree' })
}

// 查询列表
export const getResListApi = async (params?: TplQueryDto) => {
  return await request.get({ url: '/cms/siteres/list', params })
}

// 新增模板
export const createResApi = async (data: TplCreateVo) => {
  return await request.post({ url: '/cms/siteres/save', data })
}

// 修改模板
export const updateResApi = async (data: TplUpdateVo) => {
  return await request.post({ url: '/cms/siteres/update', data })
}

// 删除模板资源
export const deleteResApi = async (names: String) => {
  return await request.post({ url: '/cms/siteres/delete?names=' + names })
}

// 查询详情
export const getResDetail = async (filename: String) => {
  return await request.get({ url: '/cms/siteres/detail?name=' + filename })
}

//新建目录
export const createDirApi = async (data: TplCreateDirVo) => {
  return await request.post({ url: '/cms/siteres/dir', data })
}
